package com.lau.controller;


import com.lau.eunms.FunctionModuleEnum;
import com.lau.eunms.OperateTypeEnum;
import com.lau.log.SysLog;
import com.lau.pojo.TSysUser;
import com.lau.service.TSysUserService;
import com.lau.utils.SpringUtils;
import com.lau.vo.PagingData;
import com.lau.vo.PagingParams;
import com.lau.vo.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 系统_用户认证 前端控制器
 * </p>
 *
 * @author Lau
 * @since 2022-12-07
 */
@RestController
@RequestMapping("/sys/user")
public class TSysUserController extends BaseController {

    @Autowired
    TSysUserService userService;

    @GetMapping("/hello")
    public String hello() throws InterruptedException {
        userService.testOrderExpiration();
        return "hello SpringBoot";
    }


    @SysLog(name="根据登录名获取用户信息",module = FunctionModuleEnum.USER,operateType = OperateTypeEnum.QUERY)
    @GetMapping("/queryUserListByLoginName")
    public ResultData<List<TSysUser>> queryUserListByLoginName(String loginName){
        return success(userService.queryUserListByLoginName(loginName));
    }

    @SysLog(name="根据条件获取用户信息",module = FunctionModuleEnum.USER,operateType = OperateTypeEnum.QUERY)
    @GetMapping("/queryUserListByCondition")
    public ResultData<List<TSysUser>> queryUserListByCondition(String userName,String loginName){
        return success(userService.queryUserListByCondition(userName,loginName));
    }

    @SysLog(name="根据条件获取用户信息(分页)",module = FunctionModuleEnum.USER,operateType = OperateTypeEnum.QUERY)
    @GetMapping("/pageUserListByCondition")
    public ResultData<PagingData<TSysUser>> pageUserListByCondition(String userName,String loginName, PagingParams pageParams){
        return success(userService.pageUserListByCondition(userName,loginName,pageParams));
    }


    @SysLog(name="根据用户名获取用户信息",module = FunctionModuleEnum.USER,operateType = OperateTypeEnum.QUERY)
    @GetMapping("/queryUserListByName")
    public ResultData<List<TSysUser>> queryUserListByName(String name){
        return success(userService.queryUserListByName(name));
    }

    @SysLog(name="根据用户名获取用户信息(分页)",module = FunctionModuleEnum.USER,operateType = OperateTypeEnum.QUERY)
    @GetMapping("/pageUserListByName")
    public ResultData<PagingData<TSysUser>> pageUserListByName(String name, PagingParams pageParams){
        return success(userService.pageUserListByName(name,pageParams));
    }

    @GetMapping("/queryUserListById")
    public ResultData<TSysUser> queryUserListById(String id){
        return success(userService.queryUserListById(id));
    }

    @GetMapping("/test")
    public void test() throws Exception {
         userService.test();
    }
}

